 <?
if (!defined('baseinfo')) {
    exitdata();
}   
?>
<div class="subB clTxt1 fs05 clBg4">
    <div class="wrpSubB mainSB">
        <div class="ttlB cutTxt">Cart</div>
    </div>
</div>
<div class="wrprCart">
    <div class="wrpTgHdGen clBd2 bdBtm clTxt2 fs05">
        <span class="tgHdGen tgCl clBd2 bdR clSp2" id="set-wrprMyCart" onclick="changetabcart('wrprMyCart')">My Cart</span>
        <span class="tgHdGen tgCl clBd2 bdR" id="set-wrprOrdHtr" onclick="changetabcart('wrprOrdHtr')">Order History</span>
        <span class="tgHdGen tgCl clBd2 " id="set-wrprMyPnt" onclick="changetabcart('wrprMyPnt')">My Point</span>
        <!--<span class="tgHdGen tgCl clBd2" id="set-wrprMyCrd" onclick="changetabcart('wrprMyCrd')">My Credit</span>-->
        
    </div>
    <div class="wrpCart">
        <!-- My Cart -->
        <div class="wrprMyCart carttab">
        <?if(count($data['carthistory'])){
           foreach($data['carthistory'] as $carthistory){
           
           $arraysum=array();
           ?>
            <div class="wrpMyCart" id="shopcart-<?=$carthistory['userid']?>">
                <div class="wrprShopCart clearfix clBg1 showshopname">
                   <a href="<?=baseinfo.'/'.$carthistory['username']?>">
                        <img src="<?=$carthistory['usimg']['newpath']?>" class="genImgShp">
                        <span class="cutTxt clTxt2 fs04 " ><?=$carthistory['displayname']?></span>
                    </a>
                </div>
                <div class="wrprTbCart clBd2">
                    <div class="tbCart clTxt2">
                        <div class="wrpHdTbCart clBg2">
                            <div class="hdTbCart fs04 boldGen clearfix">
                                <span class="ct c1">Product</span>
                                <span class="ct c2">Price (Baht)</span>
                                <span class="ct c3">Quantity</span>
                                <span class="ct c4">Amount (Baht)</span>
                                <span class="ct c11">Pay with Points</span>
                                <span class="ct c5">Remove</span>
                            </div>
                        </div>
                        <?if(count($carthistory['data'])){
                           ?>
                        <div class="wrpItmLstCart clBd2 bdBtm">
                        <? foreach($carthistory['data'] as $valuedata){?>
                            <div class="itmLstCart fs03 clearfix clBd2 itmproductids" id="productids-<?=$valuedata['productid']?>">
                                <div class="ct c1 clearfix">
                                    <div class="pdImgCart">
                                        <img alt="img" src="<?=$valuedata['simg']['newpath']?>">
                                        <input type="hidden" name="suborderid" value="<?=$valuedata['suborderid']?>" > 
                                        <input type="hidden" name="productid" value="<?=$valuedata['productid']?>" > 
                                    </div>
                                    <div class="pdNameCart">
                                        <a class="boldGen" href="<?=baseinfo.'/post/'.$valuedata['productid']?>"><?=$valuedata['title']?></a>
<!--                                        <span>Main Attribute : Sub Attribute</span>
                                        <span>Note</span>-->
                                    </div>
                                </div>
                                <div class="ct c2 clearfix"><span class="pricenowset"><?=$valuedata['price']?></span></div>
                                <div class="ct c3 clearfix">
                                    <div class="iC3 clearfix">
                                        <input type="text" readonly="readonly" name="quantityset" value="<?=$valuedata['quantity']?>" class="clBg5 clBd2 fs03 clTxt2">
                                        <div class="btnC3 increproductq">
                                        <? if($valuedata['paypoint']!='1'){?>
                                            <button class="clTxtW cutTxt clBgBt1 fs04" onclick="increquantity(<?=$carthistory['userid']?>,<?=$valuedata['productid']?>)">+</button>
                                            <button class="clTxtW cutTxt clBgBt1 fs04" onclick="decrequantity(<?=$carthistory['userid']?>,<?=$valuedata['productid']?>)">-</button>
                                      <?}?>
                                        </div>
                                    </div>
                                </div>
                                <div class="ct c4 clearfix"><span class="priceallset"><?
                                if($valuedata['paypoint']!='1')
                                {
                                $arraysum[]=$valuedata['priceall'];
                                }
                                
                                echo $valuedata['priceall'];
                                
                                ?></span></div>
                                
                                <div class="ct c11 clearfix paytextdata">
                                    <? if($valuedata['userpoint']=='1'&&$valuedata['paypoint']=='0'){?>
                                    <button  onclick="openpaywithpoint(<?=$carthistory['userid']?>,<?=$valuedata['productid']?>,<?=$valuedata['point']?>)" class="clTxtW cutTxt clBgBt1 fs01 paywithpointdatabtn">Pay with Points</button>
                                    
                                    <?}else if($valuedata['userpoint']=='1'&&$valuedata['paypoint']=='1')
                                    {
                                    echo "Pay With Points";
                                    
                                    }?>
                                   <input type="hidden" name="paywithpoint" value="<?=$valuedata['paypoint']?>" >
                                </div>
                                <div class="ct c5 clearfix">
                                 <? if($valuedata['paypoint']!='1'){?>
                                    <div class="wrpIcoRmvCart" onclick="removeitemproduct(<?=$carthistory['userid']?>,<?=$valuedata['productid']?>)">
                                        <span class="ico icoRmvCart"></span>
                                    </div>
                                    <?}?>
                                </div>
                            </div>
                        <?}?>
                        </div>
                        <?
                            
                        }?>
                        <div class="wrpCouponCart clBd2 bdBtm">
                            <div class="addCpCart">
                                <div class="cpCart clearfix">
                                    <span class="fs03 boldGen">Coupon Code</span>
                                    <input type="text" name="creditcode" class="clBg5 clBd2 fs03 clTxt2">
                                    <input type="button" onclick="postcredit(<?=$carthistory['userid']?>)" value="Submit" class="btnGen clTxtW cutTxt clBgBt2 fs04">
                                    <div class="wrnCpCart">
                                        <!--<div class="errLS clErrBg">
                                            <span class="ico icoErr"></span>
                                        </div>
                                        <span class="spnErrLS clErrTxt fs02">This coupon code is invalid or has expired.</span>-->
                                    </div>
                                </div>
                            </div>
                            <div class="coupondiv"></div>
                            <!--
                            <div class="itmLstCart fs03 clearfix clBd2">
                                <div class="ct c10 clearfix">
                                    <span>Coupon Name</span>
                                </div>
                                <div class="ct c4 clearfix"><span>-100</span></div>
                                <div class="ct c5 clearfix">
                                    <div class="wrpIcoRmvCart">
                                        <span class="ico icoRmvCart"></span>
                                    </div>
                                </div>
                            </div>
                            -->
                        </div>
                        <?
                            if(count($carthistory['transport'])){
                            
                        ?>
                        
                        <div class="wrpRcCart clBd2 bdBtm">
                            <div class="hdRcCart">
                                <span class="fs03 boldGen">วิธีรับสินค้า</span>
                            </div>
                            <?
                            
                            
                            foreach($carthistory['transport'] as $valuetransport )
                            {
                            ?>
                            <div class="itmLstCart fs03 clearfix clBd2 transportcart">
                                <div class="ct c6">
                                    <div class="ysCart">
                                        <input type="radio" onclick="calalldata(<?=$carthistory['userid']?>)"  value="<?=$valuetransport['tspoid']?>" name="rcCart">
                                        <label class="fs03 clTxt3 transportnamedata" for="ys"><?=$valuetransport['tspname']?></label>
                                    </div>
                                </div>
                                <div class="ct c7"><span><?=$valuetransport['tspcost']?></span></div>
                            </div>
                            
                            <?
                            }
                            
                            
                           
                            ?>
            
                        </div>
                        
                        <?}?>
                        
                        <input type="hidden" name="orderid" value="<?=$carthistory['orderid']?>" > 
                        
                        <div class="wrpTotalCart">
                            <div class="totalCart fs07 boldGen clearfix">
                                <span class="ct c8">Total</span>
                                <span class="ct c9 sumallcheck"><?=array_sum($arraysum)?></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="ftMyCart clearfix">
                    <div class="btnMyCart">
                        <input type="button" value="Next" onclick="loadpopupship(<?=$carthistory['userid']?>)" class="btnGen btnNxtCrt clTxtW cutTxt clBgSp2 fs04">
                        <input type="button" value="Empty Cart" onclick="emptycartproduct(<?=$carthistory['userid']?>)" class="btnGen btnCncl clTxtW cutTxt clBgBt1 fs04">
                    </div>
                </div>
            </div>
        <?
           }
        }?>  
        </div>
        <!-- Order History -->
        <div class="wrprOrdHtr carttab" style="display: none;" >
            <div class="wrpOrdHtr">
                <div class="wrprSrchOrdHtr">
                    <div class="wrpSrchOrdHtr clearfix">
                        <div class="wrpSrchBox">
                            <input type="text" placeholder="Search" class="srchBox clBg4 fs01 clTxt3">
                            <div class="btnIco srchGen">
                                <span class="ico icoSrchGen"></span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpFiltOrdHtr">
                        <button class="btntFiltOrdHtr clTxtW clBgBt1 fs02 btnFiltOrdHtrAct" onclick="getmyorderlist(1,0)">All</button>
                        <button class="btntFiltOrdHtr clTxtW clBgBt1 fs02" onclick="getmyorderlist(1,1)">Reserve</button>
                        <button class="btntFiltOrdHtr clTxtW clBgBt1 fs02" onclick="getmyorderlist(1,2)">Paid</button>
                        <button class="btntFiltOrdHtr clTxtW clBgBt1 fs02" onclick="getmyorderlist(1,3)">Shipped</button>
                        <button class="btntFiltOrdHtr clTxtW clBgBt1 fs02" onclick="getmyorderlist(1,4)">Canceled</button>
                    </div>
                </div>
                <div class="wrprTbCart clBd2">
                    <div class="tbCart clTxt2">
                        <div class="wrpHdTbCart clBg2">
                            <div class="hdTbCart fs04 boldGen clearfix">
                                <span class="ct o1">Date</span>
                                <span class="ct o2">Shop</span>
                                <span class="ct o3">Order ID</span>
                                <span class="ct o4">Amount (Baht)</span>
                                <span class="ct o5">Status</span>
                            </div>
                        </div>
                        <div class="wrpItmLstCart clBd2 bdBtm">

                        </div>
                        <div class="pageat2cart"></div>
                    </div>
                </div>
            </div>
        </div>
        <!-- My Point -->
        <div class="wrprMyPnt carttab" style="display: none;" >
            <div class="bdMyPnt">
                <div class="wrpMyPnt">
                    <div class="myPnt clBg5 fs05 clTxt1 clearfix">
                        <span class="nameMyPnt">You Have</span>
                        <span class="wrpNumMyPnt">
                            <span class="numMyPnt clearfix">
                                <em class="fs05">Points</em>
                                <em class="fs18"><?=number_format($data['mypoint'])?></em> 
                            </span>
                        </span>
                    </div>
                    <div class="wrpHtrPnt clBg4">
                        <div class="hdHtrCrd">
                            <span class="boldGen fs04">Pay with Points History</span>
                        </div>
                        <div class="bdHtrCrd">
                            <div class="wrpHdTbCart clBg2">
                                <div class="hdTbCart fs04 boldGen clearfix">
                                    <span class="ct p1">Date</span>
                                    <span class="ct p2">Description</span>
                                    <span class="ct p3">No. of Points</span>
                                    <span class="ct p4">Balance Points</span>
                                </div>
                            </div>
                            <div class="wrpItmLstCart">
                            <!--
                                <div class="itmLstCart fs03 clBd2">
                                    <div class="wrpDtCrdHtr clBg4">
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct p1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct p2 clearfix">
                                                <em>Order ID : </em>
                                                <span class="boldGen">
                                                    <a class="btnOrdCtmView">ABC123456</a>
                                                </span>
                                            </div>
                                            <div class="ct p3 clearfix"><span>-200</span></div>
                                            <div class="ct p4 clearfix"><span>100</span></div>
                                        </div>
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct p1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct p2 clearfix">
                                                <em>Earn Points</em>
                                            </div>
                                            <div class="ct p3 clearfix"><span>200</span></div>
                                            <div class="ct p4 clearfix"><span>300</span></div>
                                        </div>
                                    </div>
                                </div>
                                -->
                            </div>
                            <div class="pageat3cart"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- My Credit -->
        <div class="wrprMyCrd carttab" style="display: none;" >
            <div class="bdMyCrd">
                <div class="wrpShopCrd">
                    <div class="shopCrd clBg5 fs05 clTxt1 clearfix">
                        <div class="nameShopCrd clearfix">
                            <a href="">
                                <img src="img/dfthmbuser.jpg" class="genImgShp">
                                <span class="cutTxt clTxt2 fs04" href="">Shop A</span>
                            </a>
                        </div>
                        <span class="wrpNumShopCrd">
                            <span class="numShopCrd clearfix">
                                <em class="fs05">Credit</em>
                                <em class="fs18">1,000</em> 
                            </span>
                        </span>
                        <div class="wrpIcoArwCrdHtr">
                            <span class="ico icoArwOrdHtr"></span>
                        </div>
                    </div>
                    <div class="wrpHtrCrd clBg4">
                        <div class="hdHtrCrd">
                            <span class="boldGen fs04">Pay with Credit History</span>
                        </div>
                        <div class="bdHtrCrd">
                            <div class="wrpHdTbCart clBg2">
                                <div class="hdTbCart fs04 boldGen clearfix">
                                    <span class="ct d1">Date</span>
                                    <span class="ct d2">Description</span>
                                    <span class="ct d3">No. of Credit</span>
                                    <span class="ct d4">Balance Credit</span>
                                </div>
                            </div>
                            <div class="wrpItmLstCart">
                                <div class="itmLstCart fs03 clBd2">
                                    <div class="wrpDtCrdHtr clBg4">
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct d1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct d2 clearfix"><span>Top Up</span></div>
                                            <div class="ct d3 clearfix"><span>200</span></div>
                                            <div class="ct d4 clearfix"><span>1,000</span></div>
                                        </div>
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct d1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct d2 clearfix">
                                                <em>Order ID : </em>
                                                <span class="boldGen">
                                                    <a class="btnOrdCtmView">ABC123456</a>
                                                </span>
                                            </div>
                                            <div class="ct d3 clearfix"><span>-200</span></div>
                                            <div class="ct d4 clearfix"><span>800</span></div>
                                        </div>
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct d1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct d2 clearfix"><span>Top Up</span></div>
                                            <div class="ct d3 clearfix"><span>1,000</span></div>
                                            <div class="ct d4 clearfix"><span>1,000</span></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="wrpShopCrd">
                    <div class="shopCrd clBg5 fs05 clTxt1 clearfix">
                        <div class="nameShopCrd clearfix">
                            <a href="">
                                <img src="img/dfthmbuser.jpg" class="genImgShp">
                                <span class="cutTxt clTxt2 fs04" href="">Shop B</span>
                            </a>
                        </div>
                        <span class="wrpNumShopCrd">
                            <span class="numShopCrd clearfix">
                                <em class="fs05">Credit</em>
                                <em class="fs18">1,000</em>
                            </span>
                        </span>
                        <div class="wrpIcoArwCrdHtr">
                            <span class="ico icoArwOrdHtr"></span>
                        </div>
                    </div>
                    <div class="wrpHtrCrd clBg4">
                        <div class="hdHtrCrd">
                            <span class="boldGen fs04">Pay with Credit History</span>
                        </div>
                        <div class="bdHtrCrd">
                            <div class="wrpHdTbCart clBg2">
                                <div class="hdTbCart fs04 boldGen clearfix">
                                    <span class="ct d1">Date</span>
                                    <span class="ct d2">Description</span>
                                    <span class="ct d3">No. of Credit</span>
                                    <span class="ct d4">Balance Credit</span>
                                </div>
                            </div>
                            <div class="wrpItmLstCart">
                                <div class="itmLstCart fs03 clBd2">
                                    <div class="wrpDtCrdHtr clBg4">
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct d1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct d2 clearfix"><span>Top Up</span></div>
                                            <div class="ct d3 clearfix"><span>200</span></div>
                                            <div class="ct d4 clearfix"><span>1,000</span></div>
                                        </div>
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct d1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct d2 clearfix"><em>Order ID : </em>
                                                <span class="boldGen">
                                                    <a class="btnOrdCtmView">ABC123456</a>
                                                </span>
                                            </div>
                                            <div class="ct d3 clearfix"><span>-200</span></div>
                                            <div class="ct d4 clearfix"><span>800</span></div>
                                        </div>
                                        <div class="wrpInDtCrdHtr clBd2 clearfix">
                                            <div class="ct d1 clearfix"><span>22/11/13</span></div>
                                            <div class="ct d2 clearfix"><span>Top Up</span></div>
                                            <div class="ct d3 clearfix"><span>1,000</span></div>
                                            <div class="ct d4 clearfix"><span>1,000</span></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
